package JUnit;

import java.sql.Date;

import DataBase.IDAOImpl.i_Notice_Impl;
import Protocal.Notice.Notice;
import junit.framework.TestCase;

public class i_Notice_ImplTest extends TestCase {

	protected void setUp() throws Exception {
		super.setUp();
		i_Notice_Impl in = new i_Notice_Impl();
		Notice notice = new Notice();
		notice.setTittle("Notice test1");
		notice.setTime(Date.valueOf("2005-12-8"));
		in.addNotice(notice);	
	}

	protected void tearDown() throws Exception {
		super.tearDown();
		i_Notice_Impl in = new i_Notice_Impl();
		in.deleteByTitle("Notice test1");
	}

	public void testAddNotice() {
		i_Notice_Impl in = new i_Notice_Impl();
		Notice notice = new Notice();
		notice.setTittle("Notice test2");
		notice.setTime(Date.valueOf("2011-12-8"));
		in.addNotice(notice);
		Notice rs = in.getByTitle("Notice test2");
		assertTrue(rs.getTittle().equalsIgnoreCase(notice.getTittle()));
		in.deleteByTitle("Notice test2");
		//fail("Not yet implemented");
	}

	public void testDeleteByTime() {
		i_Notice_Impl in = new i_Notice_Impl();
		in.deleteByTime(Date.valueOf("2005-12-9"));
		Notice rs = in.getByTitle("Notice test1");
		assertNull(rs);
		//fail("Not yet implemented");
	}

	public void testDeleteByTitle() {
		i_Notice_Impl in = new i_Notice_Impl();
		Notice notice = new Notice();
		notice.setTittle("Notice test2");
		notice.setTime(Date.valueOf("2011-12-8"));
		in.addNotice(notice);
		in.deleteByTitle("Notice test2");
		Notice rs = in.getByTitle("Notice test2");
		assertNull(rs);
		//fail("Not yet implemented");
	}

	public void testGetByTime() {
		i_Notice_Impl in = new i_Notice_Impl();
		Notice notice = new Notice();
		notice.setTittle("Notice test2");
		notice.setTime(Date.valueOf("2011-12-8"));
		in.addNotice(notice);
		Notice rs = in.getByTitle("Notice test2");
		assertTrue(rs.getTittle().equals(notice.getTittle()));
		in.deleteByTime(Date.valueOf("2005-12-9"));
		//fail("Not yet implemented");
	}

	public void testGetByTitle() {
		i_Notice_Impl in = new i_Notice_Impl();
		Notice notice = new Notice();
		notice.setTittle("Notice test2");
		notice.setTime(Date.valueOf("2011-12-8"));
		in.addNotice(notice);
	
		Notice rs = in.getByTitle("Notice test2");
		assertTrue(rs.getTittle().equals(notice.getTittle()));
		in.deleteByTitle("Notice test2");
		//fail("Not yet implemented");
	}

}
